//
//  SLBoatDetailViewController.m
//  StarLight
//
//  Created by Duke.wu on 16/5/17.
//  Copyright © 2016年 Duke.Wu. All rights reserved.
//

#import "SLBoatDetailViewController.h"
#import "SLNearlyBoatDetailViewModel.h"
#import "SLHisBoatsViewController.h"
#import "SLMapViewController.h"
#import "SLBackMsgViewController.h"
#import "STPopup.h"
#import "SLShipOwnerVipLevelView.h"
#import "SLShipImageDetailViewController.h"

@interface SLBoatDetailViewController ()

@property (nonatomic, strong) NSString *bid;

@property (nonatomic, strong) SLNearlyBoatDetailViewModel *boatDetailVM;

@property (nonatomic, strong) UIScrollView *mainScrollView;

@property (nonatomic, strong) UIView *contentView;

@property (nonatomic ,strong) UILabel *mssiLB;

@property (nonatomic ,strong) UILabel *shipNameLB;

@property (nonatomic ,strong) UILabel *packageTypeLB;

@property (nonatomic ,strong) UILabel *boatWLB;

@property (nonatomic ,strong) UILabel *boatHLB;

@property (nonatomic ,strong) UILabel *boatDLB;

@property (nonatomic ,strong) UILabel *curLocLB;

@property (nonatomic, strong) UILabel *locationLB;

@property (nonatomic, strong) UIButton *currentLocBtn;

@property (nonatomic ,strong) UILabel *distanceLB;

@property (nonatomic ,strong) UILabel *shipStatusLB;

@property (nonatomic, strong) UILabel *hWeightLB;

@property (nonatomic ,strong) UILabel *reTimeLB;

@property (nonatomic ,strong) UILabel *noteLB;

@property (nonatomic ,strong) UIButton *connectBtn;

@property (nonatomic ,strong) UIImageView *shipOwnerIcon;

@property (nonatomic ,strong) UILabel *nameLB;

@property (nonatomic ,strong) UILabel *userTypeLB;

@property (nonatomic, strong) UILabel *driveLB;

@property (nonatomic, strong) UIImageView *shipImage;

@property (nonatomic, strong) UIView *resverImageView;

@property (nonatomic, strong) UILabel *reseverLB;

@property (nonatomic, strong) UILabel *reseverTimeLB;

@property (nonatomic, strong) UILabel *vipLabel;

@property (nonatomic, strong) SLShipOwnerVipLevelView *levelView;
@end

@implementation SLBoatDetailViewController

- (instancetype)init{
  self = [super init];
  if (self) {
    _isNextAvailable = YES;
  }
  return self;
}

- (void)viewDidLoad {
    [super viewDidLoad];
  
  [self setUpUI];
  [self addConstrains];
  [self addObservers];
    // Do any additional setup after loading the view.
}

- (void)viewWillAppear:(BOOL)animated{
  [super viewWillAppear:animated];
  [self.navigationController setNavigationBarHidden:NO animated:YES];
  self.title = @"船舶详情";
}

#pragma mark - Public Methods
- (void)changeBid:(NSString *)newBid{
  _bid = newBid;
  self.boatDetailVM = [[SLNearlyBoatDetailViewModel alloc] initWithBid:newBid];
}

#pragma mark - Private Methods

- (void)addObservers{
  @weakify(self)
  
 [[ RACObserve(self.boatDetailVM, model) filter:^BOOL(id value) {
    return value != nil;
  }] subscribeNext:^(SLBoatsDetailModel *model) {
    @strongify(self)
    [self bindDataWithModel:model];
  }];
}

- (void)bindDataWithModel:(SLBoatsDetailModel *)model{
  self.mssiLB.text = [NSString stringWithFormat:@"MSSI: %@",model.mmsi];
  self.shipNameLB.text = model.boatname;
  self.packageTypeLB.text = model.boattype;
  self.boatDLB.text = [NSString stringWithFormat:@"%ld",(long)model.draft];
  self.boatHLB.text = [NSString stringWithFormat:@"%ld",(long)model.height];
  self.boatWLB.text = [NSString stringWithFormat:@"%ld",(long)model.weight];
  self.hWeightLB.text = [NSString stringWithFormat:@"%ld 吨",(long)model.loads];
  self.distanceLB.text = [NSString stringWithFormat:@"%ld 公里",(long)model.distance];
  [self setStatusWithState:model.state];
  [self.shipOwnerIcon sd_setImageWithURL:[NSURL URLWithString:model.headPhoto] placeholderImage:[UIImage imageNamed:@"head"]];
  if (model.image.length > 0) {
      [self.shipImage sd_setImageWithURL:[NSURL URLWithString:model.image]];
  }else{
    [self.shipImage removeFromSuperview];
  }
  
  self.driveLB.text = model.cockpit == 1 ? @"前置" :@"后置";
  self.userTypeLB.text = model.type == 0 ? @"船东" :@"货主";
  self.nameLB.text = model.name;
  self.reTimeLB.text = model.statetime;
  self.noteLB.text = model.note;
  if (model.state == 3) {
    self.locationLB.text = @"预定位置";
    self.curLocLB.text = model.goalloc;
    self.reseverTimeLB.text = model.reservetime;
  }else{
    self.curLocLB.text = model.shiploc;
    [self.resverImageView removeFromSuperview];
    [self.reseverTimeLB removeFromSuperview];
    [self.reseverLB removeFromSuperview];
  }
  
  if (model.role < 1) {
    [self.vipLabel removeFromSuperview];
    [self.levelView removeFromSuperview];
  }else{
    [self.levelView configWithLevel:[NSString stringWithFormat:@"%ld",(long)model.role]];
  }
  
}

- (void)setStatusWithState:(NSInteger)state{
  switch (state) {
    case 0:{
      //满载
      self.shipStatusLB.text = @"满载";
    }
      break;
    case 1:{
      //空船找货
      self.shipStatusLB.text = @"空船找货";
    }
      break;
    case 2:{
      //半船找货
      self.shipStatusLB.text = @"半船找货";
    }
      break;
    case 3:{
      //预定货物
      self.shipStatusLB.text = @"预定货物";
    }
      break;
      
    default:
      break;
  }
}

/**
 *  信息反馈
 */
- (void)toCallBack{

  SLBackMsgViewController *backMsgVC = [[SLBackMsgViewController alloc] init];
  [backMsgVC backBoatMsgWith:self.boatDetailVM.model.bid];
  STPopupController *popVC = [[STPopupController alloc] initWithRootViewController:backMsgVC];
  
  [popVC presentInViewController:self];

}

- (void)connectShipOwner{
  [self.boatDetailVM connectShipOwner];
}

- (void)getMore{
  
  if (self.isNextAvailable) {
    SLHisBoatsViewController *moreVC = [SLHisBoatsViewController new];
    [moreVC getMoreBoatWithHid:self.boatDetailVM.model.shiponwerId];
    [self.navigationController pushViewController:moreVC animated:YES];
  }
  
}

- (void)toShowMap{
  
  SLMapViewController *mapVC = [SLMapViewController new];
  if (self.boatDetailVM.model.state == 3) {
    [mapVC locationWithLon:self.boatDetailVM.model.goallon lat:self.boatDetailVM.model.goallat];
  }else{
    [mapVC locationWithLon:self.boatDetailVM.model.shiplon lat:self.boatDetailVM.model.shiplat];
  }
  
  [self.navigationController pushViewController:mapVC animated:YES];
}

- (void)seeShipImageDetail{
  SLShipImageDetailViewController *shipDetailVC = [SLShipImageDetailViewController new];
  shipDetailVC.shipImage = self.shipImage.image;
  [self.navigationController pushViewController:shipDetailVC animated:YES];
}

#pragma mark - UI 约束

- (void)setUpUI{
  [self.view addSubview:self.mainScrollView];
  [self.view addSubview:self.connectBtn];
  [self.mainScrollView addSubview:self.contentView];
  [self.contentView addSubview:self.mssiLB];
  [self.contentView addSubview:self.shipNameLB];
  [self.contentView addSubview:self.packageTypeLB];
  [self.contentView addSubview:self.boatWLB];
  [self.contentView addSubview:self.boatHLB];
  [self.contentView addSubview:self.boatDLB];
  [self.contentView addSubview:self.currentLocBtn];
  [self.contentView addSubview:self.curLocLB];
  [self.contentView addSubview:self.distanceLB];
  [self.contentView addSubview:self.shipStatusLB];
  [self.contentView addSubview:self.reTimeLB];
  [self.contentView addSubview:self.noteLB];
  [self.contentView addSubview:self.shipOwnerIcon];
  [self.contentView addSubview:self.nameLB];
  [self.contentView addSubview:self.hWeightLB];
  [self.contentView addSubview:self.reseverLB];
  [self.contentView addSubview:self.reseverTimeLB];
  [self.contentView addSubview:self.resverImageView];
  [self.contentView addSubview:self.locationLB];
  [self.contentView addSubview:self.userTypeLB];
  [self.contentView addSubview:self.vipLabel];
  [self.contentView addSubview:self.levelView];
  [self.contentView addSubview:self.shipImage];
  
  UIBarButtonItem *rightItem = [[UIBarButtonItem alloc] initWithTitle:@"反馈" style:UIBarButtonItemStylePlain target:self action:@selector(toCallBack)];
  self.navigationItem.rightBarButtonItem = rightItem;
  
  
}

- (void)addConstrains{
  
  
  CGFloat LSize = 14;
  CGFloat botPading = 12.f;
  CGFloat llPading = 8.f;
  
  [self.mainScrollView mas_makeConstraints:^(MASConstraintMaker *make) {
    make.edges.equalTo(self.view);
  }];
  
  [self.contentView mas_makeConstraints:^(MASConstraintMaker *make) {
    make.edges.equalTo(self.mainScrollView);
    make.width.equalTo(self.mainScrollView);
  }];

  [self.mssiLB mas_makeConstraints:^(MASConstraintMaker *make) {
    make.top.equalTo(self.contentView).offset(16);
    make.left.equalTo(self.contentView).offset(12);
  }];
  
  [self.shipNameLB mas_makeConstraints:^(MASConstraintMaker *make) {
    make.centerY.equalTo(self.mssiLB);
    make.right.equalTo(self.contentView).offset(-16);
  }];
#pragma mark - 第一条线
//  UIImageView *firLine = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"line"]];
  UIView *firLine = [UIView xlineView];
  [self.contentView addSubview:firLine];
  [firLine mas_makeConstraints:^(MASConstraintMaker *make) {
    make.top.equalTo(self.mssiLB.mas_bottom).offset(botPading);
    make.left.equalTo(self.mssiLB);
    make.right.equalTo(self.shipNameLB);
    make.height.equalTo(@1);
  }];

  UILabel *bpLB = [UILabel labelWithFontSize:LSize textColor:SLInkColor text:@"船舶类型"];
  [self.contentView addSubview:bpLB];
  [bpLB mas_makeConstraints:^(MASConstraintMaker *make) {
    make.top.equalTo(firLine.mas_bottom).offset(botPading);
    make.left.equalTo(self.contentView).offset(19);
  }];
  
  [self.packageTypeLB mas_makeConstraints:^(MASConstraintMaker *make) {
    make.left.equalTo(self.mssiLB);
    make.top.equalTo(bpLB.mas_bottom).offset(llPading);
  }];

  UILabel *chLB = [UILabel labelWithFontSize:LSize textColor:SLInkColor text:@"吃水"];
  [self.contentView addSubview:chLB];
  [chLB mas_makeConstraints:^(MASConstraintMaker *make) {
    make.top.equalTo(bpLB);
    make.right.equalTo(self.contentView).offset(-25);
  }];
  
  [self.boatDLB mas_makeConstraints:^(MASConstraintMaker *make) {
    make.centerY.equalTo(self.packageTypeLB);
    make.centerX.equalTo(chLB);
  }];
  
  UILabel *bhLB = [UILabel labelWithFontSize:LSize textColor:SLInkColor text:@"船高"];
  [self.contentView addSubview:bhLB];
  [bhLB mas_makeConstraints:^(MASConstraintMaker *make) {
    make.top.equalTo(bpLB);
    make.right.equalTo(chLB).offset(-65);
  }];
  
  [self.boatHLB mas_makeConstraints:^(MASConstraintMaker *make) {
    make.centerY.equalTo(self.packageTypeLB);
    make.centerX.equalTo(bhLB);
  }];
  
  UILabel *bwLB = [UILabel labelWithFontSize:LSize textColor:SLInkColor text:@"船宽"];
  [self.contentView addSubview:bwLB];
  [bwLB mas_makeConstraints:^(MASConstraintMaker *make) {
    make.top.equalTo(bpLB);
    make.right.equalTo(bhLB).offset(-65);
  }];
  
  [self.boatWLB mas_makeConstraints:^(MASConstraintMaker *make) {
    make.centerY.equalTo(self.packageTypeLB);
    make.centerX.equalTo(bwLB);
  }];
  
#pragma mark - 第二条线
//  UIImageView *secLine = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"line"]];
  UIView *secLine = [UIView xlineView];
  [self.contentView addSubview:secLine];
  [secLine mas_makeConstraints:^(MASConstraintMaker *make) {
    make.top.equalTo(self.packageTypeLB.mas_bottom).offset(llPading);
    make.height.width.centerX.equalTo(firLine);
  }];

  [self.locationLB mas_makeConstraints:^(MASConstraintMaker *make) {
    make.left.equalTo(self.mssiLB);
    make.top.equalTo(secLine.mas_bottom).offset(botPading);
  }];
  
  [self.curLocLB mas_makeConstraints:^(MASConstraintMaker *make) {
    make.left.equalTo(self.mssiLB);
    make.top.equalTo(self.locationLB.mas_bottom).offset(llPading);
    make.width.lessThanOrEqualTo(@(120*MIX_W));
  }];

  [self.currentLocBtn mas_makeConstraints:^(MASConstraintMaker *make) {
    make.centerY.equalTo(self.curLocLB);
    make.right.equalTo(self.shipNameLB).offset(-10);
  }];
  
#pragma mark - 第三条线
  
//  UIImageView *thridLine = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"line"]];
  UIView *thridLine = [UIView xlineView];
  [self.contentView addSubview:thridLine];
  [thridLine mas_makeConstraints:^(MASConstraintMaker *make) {
    make.top.equalTo(self.curLocLB.mas_bottom).offset(botPading);
    make.height.width.centerX.equalTo(firLine);
  }];
  
  
  UILabel *clLB = [UILabel labelWithFontSize:LSize textColor:SLInkColor text:@"距离"];
  [self.contentView addSubview:clLB];
  [clLB mas_makeConstraints:^(MASConstraintMaker *make) {
    make.top.equalTo(thridLine.mas_bottom).offset(botPading);
    make.left.equalTo(bpLB);
  }];
  
  [self.distanceLB mas_makeConstraints:^(MASConstraintMaker *make) {
    make.left.equalTo(self.mssiLB);
    make.top.equalTo(clLB.mas_bottom).offset(llPading);
  }];

  
  UILabel *dwLB = [UILabel labelWithFontSize:LSize textColor:SLInkColor text:@"吨位"];
  [self.contentView addSubview:dwLB];
  [dwLB mas_makeConstraints:^(MASConstraintMaker *make) {
    make.top.equalTo(thridLine.mas_bottom).offset(llPading);
    make.centerX.equalTo(chLB);
  }];
  
  [self.hWeightLB mas_makeConstraints:^(MASConstraintMaker *make) {
    make.top.equalTo(dwLB.mas_bottom).offset(botPading);
    make.right.equalTo(self.shipNameLB);
  }];
  
  
  
#pragma mark - 第四条线
  
//  UIImageView *forthLine = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"line"]];
  UIView *forthLine = [UIView xlineView];
  [self.contentView addSubview:forthLine];
  [forthLine mas_makeConstraints:^(MASConstraintMaker *make) {
    make.top.equalTo(self.distanceLB.mas_bottom).offset(botPading);
    make.height.width.centerX.equalTo(firLine);
  }];
  
  UILabel *bsLB = [UILabel labelWithFontSize:LSize textColor:SLInkColor text:@"状态"];
  [self.contentView addSubview:bsLB];
  [bsLB mas_makeConstraints:^(MASConstraintMaker *make) {
    make.top.equalTo(forthLine.mas_bottom).offset(botPading);
    make.left.equalTo(bpLB);
  }];

  [self.shipStatusLB mas_makeConstraints:^(MASConstraintMaker *make) {
    make.top.equalTo(bsLB.mas_bottom).offset(llPading);
    make.left.equalTo(self.mssiLB);
  }];

  UILabel *drivelabel = [UILabel labelWithFontSize:LSize textColor:[UIColor blackColor] text:@"驾驶舱"];
  [self.contentView addSubview:drivelabel];
  [self.contentView addSubview:self.driveLB];
  
  [drivelabel mas_makeConstraints:^(MASConstraintMaker *make) {
    make.centerX.equalTo(self.contentView);
    make.top.equalTo(bsLB);
  }];
  
  [self.driveLB mas_makeConstraints:^(MASConstraintMaker *make) {
    make.centerY.equalTo(self.shipStatusLB);
    make.centerX.equalTo(drivelabel);
  }];

  UILabel *retLB = [UILabel labelWithFontSize:LSize textColor:SLInkColor text:@"更新时间"];
  [self.contentView addSubview:retLB];
  [retLB mas_makeConstraints:^(MASConstraintMaker *make) {
    make.top.equalTo(bsLB);
    make.right.equalTo(chLB);
  }];

  [self.reTimeLB mas_makeConstraints:^(MASConstraintMaker *make) {
    make.top.equalTo(self.shipStatusLB);
    make.right.equalTo(self.shipNameLB);
  }];

#pragma mark - 第五条线
  
//  UIImageView *fifthLine = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"line"]];
  UIView *fifthLine = [UIView xlineView];
  [self.contentView addSubview:fifthLine];
  [fifthLine mas_makeConstraints:^(MASConstraintMaker *make) {
    make.top.equalTo(self.shipStatusLB.mas_bottom).offset(botPading);
    make.height.width.centerX.equalTo(firLine);
  }];
  
  
  [self.reseverLB mas_makeConstraints:^(MASConstraintMaker *make) {
    make.top.equalTo(fifthLine.mas_bottom).offset(botPading);
    make.left.equalTo(bsLB);
  }];
  
  [self.reseverTimeLB mas_makeConstraints:^(MASConstraintMaker *make) {
    make.top.equalTo(self.reseverLB.mas_bottom).offset(llPading);
    make.left.equalTo(self.reseverLB);
  }];
  
  [self.resverImageView mas_makeConstraints:^(MASConstraintMaker *make) {
    make.top.equalTo(self.reseverTimeLB.mas_bottom).offset(botPading);
    make.height.width.centerX.equalTo(firLine);
  }];
  
  UILabel *notLB = [UILabel labelWithFontSize:LSize textColor:SLInkColor text:@"备注: "];
  [self.contentView addSubview:notLB];
  [notLB mas_makeConstraints:^(MASConstraintMaker *make) {
    make.top.equalTo(self.resverImageView.mas_bottom).offset(botPading).priorityHigh(150);
    make.top.equalTo(fifthLine.mas_bottom).offset(botPading).priority(50);
    make.left.equalTo(bsLB);
  }];
  
  [self.noteLB mas_makeConstraints:^(MASConstraintMaker *make) {
    make.top.equalTo(notLB.mas_bottom).offset(llPading);
    make.left.equalTo(self.mssiLB);
    make.right.equalTo(chLB).offset(5);
  }];
  
#pragma mark - 第六条线
  
//  UIImageView *sixLine = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"line"]];
  UIView *sixLine = [UIView xlineView];
  [self.contentView addSubview:sixLine];
  [sixLine mas_makeConstraints:^(MASConstraintMaker *make) {
    make.top.equalTo(self.noteLB.mas_bottom).offset(botPading);
    make.height.width.centerX.equalTo(firLine);
  }];
  
  [self.shipImage mas_makeConstraints:^(MASConstraintMaker *make) {
    make.top.equalTo(sixLine.mas_bottom).offset(botPading);
    make.centerX.equalTo(self.contentView);
    make.width.equalTo(self.contentView).offset(-40);
    make.height.equalTo(@100);
  }];
  
#pragma mark - 第七条线
  
//  UIImageView *sevenLine = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"line"]];
  UIView *sevenLine = [UIView xlineView];
  [self.contentView addSubview:sevenLine];
  [sevenLine mas_makeConstraints:^(MASConstraintMaker *make) {
    make.top.equalTo(self.shipImage.mas_bottom).offset(botPading).priorityHigh(100);
    make.top.equalTo(sixLine).priorityMedium(50);
    make.height.width.centerX.equalTo(firLine);
  }];
  
  [self.shipOwnerIcon mas_makeConstraints:^(MASConstraintMaker *make) {
    make.size.mas_equalTo(CGSizeMake(34, 34));
    make.top.equalTo(sevenLine.mas_bottom).offset(botPading);
    make.left.equalTo(self.mssiLB);
  }];
  
  [self.nameLB mas_makeConstraints:^(MASConstraintMaker *make) {
    make.left.equalTo(self.shipOwnerIcon.mas_right).offset(10);
    make.centerY.equalTo(self.shipOwnerIcon);
  }];
  
  [self.userTypeLB mas_makeConstraints:^(MASConstraintMaker *make) {
    make.left.equalTo(self.nameLB.mas_right).offset(12);
    make.centerY.equalTo(self.nameLB);
  }];
  [self.vipLabel mas_makeConstraints:^(MASConstraintMaker *make) {
    make.left.equalTo(self.userTypeLB.mas_right);
    make.top.equalTo(self.userTypeLB);
  }];

  [self.levelView mas_makeConstraints:^(MASConstraintMaker *make) {
    make.centerY.equalTo(self.vipLabel);
    make.left.equalTo(self.vipLabel.mas_right).offset(5);
    make.size.mas_equalTo(CGSizeMake(20, 20));
  }];
  
  
  
  UIImageView *eightLine = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"line"]];
  [self.contentView addSubview:eightLine];
  [eightLine mas_makeConstraints:^(MASConstraintMaker *make) {
    make.top.equalTo(self.userTypeLB.mas_bottom).offset(botPading);
    make.height.width.centerX.equalTo(firLine);
  }];
  
  [self.contentView mas_makeConstraints:^(MASConstraintMaker *make) {
    make.bottom.equalTo(eightLine.mas_bottom).offset(70);
  }];
  
  UIButton *allButton = [UIButton buttonWithTitle:@"更多 >"];
  [allButton addTarget:self action:@selector(getMore) forControlEvents:UIControlEventTouchUpInside];
  [allButton setTitleColor:SLYellowColor forState:UIControlStateNormal];
  allButton.titleLabel.font = [UIFont boldSystemFontOfSize:16];
  [self.contentView addSubview:allButton];
  [allButton mas_makeConstraints:^(MASConstraintMaker *make) {
    make.centerY.equalTo(self.nameLB);
    make.right.equalTo(self.contentView).offset(-37);
    make.size.mas_equalTo(CGSizeMake(60, 20));
  }];
  

  [self.connectBtn mas_makeConstraints:^(MASConstraintMaker *make) {
    make.height.equalTo(@45);
    make.width.equalTo(self.view).offset(-10);
    make.centerX.equalTo(self.view);
    make.bottom.equalTo(self.view).offset(-5);
  }];
  
  
}



- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

#pragma mark - getter

- (UILabel *)labelBoldWithText:(NSString *)text{
  
  return [UILabel labelwithBoldFontSize:20 textColor:[UIColor blackColor] text:text];
}

- (UIView *)resverImageView{
  if (!_resverImageView) {
    _resverImageView = [UIView xlineView];
  }
  return _resverImageView;
}

- (UILabel *)reseverLB{
  if (!_reseverLB) {
    _reseverLB =[UILabel labelWithFontSize:14 textColor:SLInkColor text:@"预定时间"];
  }
  return _reseverLB;
}
- (UILabel *)reseverTimeLB{
  if (!_reseverTimeLB) {
    _reseverTimeLB = [self labelBoldWithText:@""];
  }
  return _reseverTimeLB;
}

- (UIButton *)connectBtn{
  if (!_connectBtn) {
    _connectBtn = [UIButton buttonWithTitle:@"电话联系"];
    _connectBtn.backgroundColor = SLYellowColor;
    [_connectBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [_connectBtn addTarget:self action:@selector(connectShipOwner) forControlEvents:UIControlEventTouchUpInside];
  }
  return _connectBtn;
}

- (UIImageView *)shipImage{
  if (!_shipImage) {
    _shipImage = [[UIImageView alloc] init];
    _shipImage.contentMode = UIViewContentModeScaleAspectFit;
    _shipImage.userInteractionEnabled = YES;
    _shipImage.backgroundColor = [UIColor whiteColor];
    UITapGestureRecognizer *tapGes = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(seeShipImageDetail)];
    [_shipImage addGestureRecognizer:tapGes];
  }
  return _shipImage;
}

- (UIImageView *)shipOwnerIcon{
  if (!_shipOwnerIcon) {
    _shipOwnerIcon = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"head"]];
    _shipOwnerIcon.backgroundColor = SLYellowColor;
  }
  return _shipOwnerIcon;
}

- (UILabel *)nameLB{
  if (!_nameLB) {
    _nameLB = [UILabel labelwithBoldFontSize:18 textColor:SLBlackColor text:@""];
  }
  return _nameLB;
}

- (UILabel *)userTypeLB{
  if (!_userTypeLB) {
    _userTypeLB = [UILabel labelwithBoldFontSize:18 textColor:SLBlackColor text:@""];
  }
  return _userTypeLB;
}

- (UILabel *)noteLB{
  if (!_noteLB) {
    _noteLB = [self labelBoldWithText:@""];
    _noteLB.numberOfLines = 0;
  }
  return _noteLB;
}

- (UILabel *)reTimeLB{
  if (!_reTimeLB) {
    _reTimeLB = [UILabel labelwithBoldFontSize:20 textColor:SLRedColor text:@""];
  }
  return _reTimeLB;
}

- (UILabel *)shipStatusLB{
  if (!_shipStatusLB) {
    _shipStatusLB = [self labelBoldWithText:@""];
  }
  return _shipStatusLB;
}

- (UILabel *)distanceLB{
  if (!_distanceLB) {
    _distanceLB = [self labelBoldWithText:@""];
  }
  return _distanceLB;
}

- (UILabel *)curLocLB{
  if (!_curLocLB) {
    _curLocLB = [self labelBoldWithText:@""];
  }
  return _curLocLB;
}

- (UIButton *)currentLocBtn{
  if (!_currentLocBtn) {
    _currentLocBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [_currentLocBtn setImage:[UIImage imageNamed:@"map2"] forState:UIControlStateNormal];
    [_currentLocBtn addTarget:self action:@selector(toShowMap) forControlEvents:UIControlEventTouchUpInside];
  }
  return _currentLocBtn;
}



- (UILabel *)boatDLB{
  if (!_boatDLB) {
    _boatDLB = [self labelBoldWithText:@""];
  }
  return _boatDLB;
}

- (UILabel *)boatHLB{
  if (!_boatHLB) {
    _boatHLB = [self labelBoldWithText:@""];
  }
  return _boatHLB;
}

- (UILabel *)boatWLB{
  if (!_boatWLB) {
    _boatWLB = [self labelBoldWithText:@""];
  }
  return _boatWLB;
}

- (UILabel *)packageTypeLB{
  if (!_packageTypeLB) {
    _packageTypeLB = [self labelBoldWithText:@""];
  }
  return _packageTypeLB;
}

- (UILabel *)shipNameLB{
  if (!_shipNameLB) {
    _shipNameLB = [UILabel labelwithBoldFontSize:20 textColor:SLYellowColor text:@"ShipName"];
  }
  return _shipNameLB;
}

- (UILabel *)mssiLB{
  if (!_mssiLB) {
    _mssiLB = [UILabel labelwithBoldFontSize:20 textColor:[UIColor blackColor] text:@"MSSI:"];
  }
  return _mssiLB;
}

- (UIView *)contentView{
  if (!_contentView) {
    _contentView = [[UIView alloc] init];
    _contentView.backgroundColor = [UIColor whiteColor];
  }
  return _contentView;
}

- (UIScrollView *)mainScrollView{
  if (!_mainScrollView) {
    _mainScrollView = [[UIScrollView alloc] init];
    _mainScrollView.backgroundColor = [UIColor defeutBackgroudColor];
  }
  return _mainScrollView;
}

- (UILabel *)driveLB{
  if (!_driveLB) {
    _driveLB = [self labelBoldWithText:@""];
  }
  return _driveLB;
}

- (UILabel *)hWeightLB{
  if (!_hWeightLB) {
    _hWeightLB = [self labelBoldWithText:@""];
  }
  return _hWeightLB;
}

- (UILabel *)locationLB{
  if (!_locationLB) {
    _locationLB = [UILabel labelWithFontSize:14 textColor:SLInkColor text:@"当前位置"];
  }
  return _locationLB;
}

-(UILabel *)vipLabel{
  if (!_vipLabel) {
    _vipLabel = [UILabel labelwithBoldFontSize:18 textColor:[UIColor redColor] text:@"VIP"];
  }
  return _vipLabel;
}

- (SLShipOwnerVipLevelView *)levelView{
  if (!_levelView) {
    _levelView = [SLShipOwnerVipLevelView new];
  }
  return _levelView;
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
